package com.niit.onlinemusicserver34.controller;

import com.niit.onlinemusicserver34.common.R;
import com.niit.onlinemusicserver34.model.request.SongListRequest;
import com.niit.onlinemusicserver34.service.SongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/songlist")
public class SongListController {

    @Autowired
    SongListService songListService;

    @RequestMapping("/list")
    public R list(){
        return songListService.listAll();
    }

    @PostMapping("/insert")
    public R list(@RequestBody SongListRequest songListRequest){
        return songListService.saveSongList(songListRequest);
    }

    @DeleteMapping("/delete")
    public R list(@RequestParam("id") Integer id){
        return songListService.deleteSongList(id);
    }

    @PostMapping("/update")
    public R update(@RequestBody  SongListRequest songListRequest){
        return songListService.updateSongList(songListRequest);
    }

    @RequestMapping("/songStyleData")
    public R getSongStyleData(){
        return songListService.getSongListStyleData();
    }

    // 返回标题包含文字的歌单
    @GetMapping("/likeTitle/detail")
    public R songListOfLikeTitle(@RequestParam String title) {
        return songListService.likeTitle(title);
    }

    // 返回指定类型的歌单
    @GetMapping("/style/detail")
    public R songListOfStyle(@RequestParam String style) {
        return songListService.likeStyle(style);
    }
}
